﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ProspectingList.aspx.cs" Inherits="House客户端.ProspectingList" %>

<!DOCTYPE html>
<html>
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>勘察页面</title>
    <link href="easyui/easyui/1.3.4/themes/default/easyui.css" rel="stylesheet" />
    <link href="easyui/easyui/1.3.4/themes/icon.css" rel="stylesheet" />
    <link href="easyui/easyui/1.3.4/demo/demo.css" rel="stylesheet" />
</head>
<body id="zhi">
    <div style="padding: 3px">
        <select class="easyui-combobox" id="deptartment" style="width: 120px">
            <option value="所属部门">所属部门</option>
        </select>
        <select class="easyui-combobox" id="users">
            <option value="请选择">请选择</option>
        </select>
        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search',toggle:true" id="query">查询</a>
    </div>
    <div>
        <a href="#" class="easyui-linkbutton" id="EALocation">区位状况勘察</a>&nbsp;
        <a href="#" class="easyui-linkbutton" id="VillageProspecting">小区状况勘察</a>&nbsp;
        <a href="#" class="easyui-linkbutton" id="PublicProspecting">楼状况勘察</a>&nbsp;
        <a href="#" class="easyui-linkbutton" id="InquiryRecord">询价记录</a>&nbsp;
        <a href="#" class="easyui-linkbutton" id="IndoorProspecting">室内勘察</a>
        <a href="#" class="easyui-linkbutton" id="ScenePhoto">现场照片提供</a>
        <a href="#" class="easyui-linkbutton" id="XiangQing">评估详情</a>&nbsp;
        <a href="#" class="easyui-linkbutton" id="AuditDetails">审核详情</a>&nbsp;
        <a href="#" class="easyui-linkbutton" id="submit">提交</a>
    </div>
    <div>
        <table id="list">
        </table>
    </div>
    <script src="easyui/easyui/1.3.4/jquery.min.js"></script>
    <script src="easyui/easyui/1.3.4/jquery.easyui.min.js"></script>
    <script src="jquery-easyui-1.5.2/Common.js"></script>
    <script type="text/javascript" src="../easyui/jquery.params.js"></script>
    <script>
        ///绑定数据
        $(function () {
            $('#list').datagrid({
                singleSelect: true,
                columns: [[
                 { field: 'ck', checkbox: true, title: '操作', width: 100 },
                 { field: 'ProjectNumber', title: '项目号', width: 100 },
                 { field: 'The_Department', title: '所属部门', width: 100, },
                 { field: 'Loan_Contacts', title: '联系人', width: 100, },
                 { field: 'Loan_ContactsTEL', title: '联系电话', width: 100 },
                 { field: 'Basic_Quota', title: '房屋坐落', width: 100 },
                 { field: 'Basic_CreateTime', title: '登记日期', width: 150 },
                 {
                     field: 'Basic_State', title: '项目状态', width: 100,
                     formatter: function (value, row, index) {
                         return row.Basic_State == 1 ? "待约勘" : row.Basic_State == 2 ? "已勘察" : row.Basic_State == 3 ? "待审核" : row.Basic_State == 4 ? "初审未通过" : row.Basic_State == 5 ? "初审通过" : row.Basic_State == 6 ? "终审未通过" : row.Basic_State == 7 ? "终审通过" : row.Basic_State == 8 ? "勘查中" : ""
                     }
                 }
                ]]
            });
            var Survey = $("#users").combobox("getValue");
            $.ajax({
                type: "get",
                url: WebApiURL + "api/Prospecting/GetProspectingList/?Survey=" + Survey,
                success: function (data) {
                    data = eval(data);
                    $("#list").datagrid("loadData", data);
                }
            });
        });
        // 绑定部门表的信息
        $.ajax({
            type: "Get",
            url: WebApiURL + "api/Department",
            success: function (obj) {
                obj = eval(obj);
                $("#deptartment").combobox({
                    editable: false,
                    data: obj,
                    valueField: "ID",
                    textField: "Department_Name",
                });
            }
        });
        $("#users").combobox({
            editable: false,
        });
        $("#deptartment").combobox({
            onSelect: function () {
                var deptid = $("#deptartment").combobox('getValue');
                // 绑定员工信息
                $.ajax({
                    type: "Get",
                    url: WebApiURL + "api/Users/GetUserListByDeptID/?id=" + deptid,
                    success: function (obj) {
                        obj = eval(obj);
                        $("#users").combobox({
                            editable: false,
                            data: obj,
                            valueField: "Users_Name",
                            textField: "Users_Name",
                        });
                    }
                });
            }
        })
        ///区位勘察
        $("#EALocation").bind("click", function () {
            var checkedItems = $('#list').datagrid('getChecked');
            var ProjectNumber = "";
            var state = "";
            $.each(checkedItems, function (index, item) {
                ProjectNumber = item.ProjectNumber;
                state = item.Basic_State;
            });
            if (checkedItems.length != 1) {
                $.messager.alert("温馨提示", "每次只能勘察一个项目！");
                return;
            }
            if (state != 1 && state != 8) {
                $.messager.alert("温馨提示", "项目已经提交！");
                return;
            }
            location.href = 'LocationProspecting.aspx?ProjectNumber=' + ProjectNumber;

        });
        //跳转公共状况勘察
        $("#PublicProspecting").bind("click", function () {
            var checkedItems = $('#list').datagrid('getChecked');
            var ProjectNumber = "";
            var state = "";
            $.each(checkedItems, function (index, item) {
                ProjectNumber = item.ProjectNumber;
                state = item.Basic_State;
            });
            if (checkedItems.length != 1) {
                $.messager.alert("温馨提示", "每次只能勘察一个项目！");
                return;
            }
            if (state != 1 && state != 8) {
                $.messager.alert("温馨提示", "项目已经提交！");
                return;
            }
            location.href = 'PublicProspecting.aspx?ProjectNumber=' + ProjectNumber;
        });
        //跳转室内状况勘察
        $("#IndoorProspecting").bind("click", function () {
            var checkedItems = $('#list').datagrid('getChecked');
            var ProjectNumber = "";
            var state = "";
            $.each(checkedItems, function (index, item) {
                ProjectNumber = item.ProjectNumber;
                state = item.Basic_State;
            });
            if (checkedItems.length != 1) {
                $.messager.alert("温馨提示", "每次只能勘察一个项目！");
                return;
            }
            if (state != 1 && state != 8) {
                $.messager.alert("温馨提示", "项目已经提交！");
                return;
            }
            location.href = 'IndoorProspecting.aspx?ProjectNumber=' + ProjectNumber;
        });
        //跳转现场照片
        $("#ScenePhoto").bind("click", function () {
            var checkedItems = $('#list').datagrid('getChecked');
            var ProjectNumber = "";
            var state = "";
            $.each(checkedItems, function (index, item) {
                ProjectNumber = item.ProjectNumber;
                state = item.Basic_State;
            });
            if (checkedItems.length != 1) {
                $.messager.alert("温馨提示", "每次只能勘察一个项目！");
                return;
            }
            if (state != 1 && state != 8) {
                $.messager.alert("温馨提示", "项目已经提交！");
                return;
            }
            location.href = 'ScenePhoto.aspx?ProjectNumber=' + ProjectNumber;
        });
        //跳转小区状况勘察
        $("#VillageProspecting").bind("click", function () {
            var checkedItems = $('#list').datagrid('getChecked');
            var ProjectNumber = "";
            var state = "";
            $.each(checkedItems, function (index, item) {
                ProjectNumber = item.ProjectNumber;
                state = item.Basic_State;
            });
            if (checkedItems.length != 1) {
                $.messager.alert("温馨提示", "每次只能勘察一个项目！");
                return;
            }
            if (state != 1 && state != 8) {
                $.messager.alert("温馨提示", "项目已经提交！");
                return;
            }
            location.href = 'VillageProspecting.aspx?ProjectNumber=' + ProjectNumber;
        });
        //跳转详情页面
        $("#XiangQing").bind("click", function () {
            var checkedItems = $('#list').datagrid('getChecked');
            var ProjectNumber = "";
            var state = "";
            $.each(checkedItems, function (index, item) {
                ProjectNumber = item.ProjectNumber;
                state = item.Basic_State;
            });
            if (checkedItems.length != 1) {
                $.messager.alert("温馨提示", "每次只能勘察一个项目！");
                return;
            }
            if (state == 1, state == 2 || state == 8) {
                $.messager.alert("温馨提示", "项目未评估，无法查看详情！");
                return;
            }
            location.href = 'Particulars.aspx?ProjectNumber=' + ProjectNumber;
        });
        //跳转询价记录
        $("#InquiryRecord").bind("click", function () {
            var checkedItems = $('#list').datagrid('getChecked');
            var ProjectNumber = "";
            var state = "";
            $.each(checkedItems, function (index, item) {
                ProjectNumber = item.ProjectNumber;
                state = item.Basic_State;
            });
            if (checkedItems.length != 1) {
                $.messager.alert("温馨提示", "每次只能勘察一个项目！");
                return;
            }
            if (state != 1 && state != 8) {
                $.messager.alert("温馨提示", "项目已经提交！");
                return;
            }
            location.href = 'InquiryRecord.aspx?ProjectNumber=' + ProjectNumber;
        });
        //提交
        $("#submit").bind("click", function () {
            var checkedItems = $('#list').datagrid('getChecked');
            var ProjectNumber = "";
            var state = "";
            $.each(checkedItems, function (index, item) {
                ProjectNumber = item.ProjectNumber;
                state = item.Basic_State;
            });
            if (checkedItems.length != 1) {
                $.messager.alert("温馨提示", "每次只能提交一个项目！");
                return;
            }
            if (state != 1 && state != 8) {
                $.messager.alert("温馨提示", "项目已经提交！");
                return;
            }
            $.ajax({
                type: "post",
                url: WebApiURL + "api/Prospecting/UpdateState?ProjectNumberber=" + ProjectNumber,
                success: function (data) {
                    if (data > 0) {
                        $.messager.alert("温馨提示", "提交成功！");
                        location.href = 'ProspectingList.aspx';
                        return;
                    } else {
                        $.messager.alert("温馨提示", "提交失败！");
                        return;
                    }
                }
            });
        });
        //查询
        $("#query").bind("click", function () {
            var Survey = $("#users").combobox("getValue");
            $.ajax({
                type: "get",
                url: WebApiURL + "api/Prospecting/GetProspectingList/?Survey=" + Survey,
                success: function (data) {
                    data = eval(data);
                    $("#list").datagrid("loadData", data);
                }
            });
        });
        //跳转审核详情页面
        $("#AuditDetails").bind("click", function () {
            var checkedItems = $('#list').datagrid('getChecked');
            var ProjectNumber = "";
            var state = "";
            $.each(checkedItems, function (index, item) {
                ProjectNumber = item.ProjectNumber;
                state = item.Basic_State;
            });
            if (checkedItems.length != 1) {
                $.messager.alert("温馨提示", "请选择要查看的项目！");
                return;
            }
            if (state == 4 || state == 5 || state == 6 || state == 7) {
                location.href = 'AuditDetails.aspx?ProjectNumber=' + ProjectNumber;
                return;
            }
            $.messager.alert("温馨提示", "项目还未审核，无法查看审核详情！");
        });
    </script>
</body>
</html>
